package com.spring.cn.config.factoryBean;

import org.springframework.beans.factory.FactoryBean;

/**
 * @author liangd
 * date 2020-11-14 15:09
 * code 自定义FactoryBean需要实现FactoryBean接口
 */
public class CarFactoryBean implements FactoryBean<CarBean> {

    private String brand;

    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * 返回bean的对象
     */
    @Override
    public CarBean getObject() throws Exception {
//        return new CarBean("BWM", 500000);
        return new CarBean(brand, 500000);
    }

    /**
     * 返回bean的实例
     */
    @Override
    public Class<?> getObjectType() {
        return CarBean.class;
    }

    /**
     * 是否是单实例
     */
    @Override
    public boolean isSingleton() {
        return true;
    }
}
